//
//  LGPatientSportsEvaCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/11/7.
//  运动康复 - 评估记录

#import "LGPatientSportsEvaCell.h"
#import "SVGKit.h"
#import "SVGKImage.h"
#import "SVGKParser.h"

@interface LGPatientSportsEvaCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIImageView *iconView;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *tipLabel;
/**   */
@property (nonatomic , strong)UILabel *timeLabel;

@end

@implementation LGPatientSportsEvaCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}


-(void)setModel:(LGEvaluationModel *)model{
    _model = model;
//    self.iconView.image = [SVGKImage imageWithContentsOfURL:[NSURL URLWithString:model.icon]].UIImage;
    self.iconView.image = model.image;
    self.titleLabel.text = model.title;
    self.timeLabel.text = (model.eva_date.length>0) ? model.eva_date : @"暂未评估";
    self.tipLabel.hidden = (model.eva_date.length>0) ? NO : YES;
    
}


-(void)createSubView{
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.baseView];
    [self.baseView addSubview:self.iconView];
    [self.baseView addSubview:self.titleLabel];
    [self.baseView addSubview:self.tipLabel];
    [self.baseView addSubview:self.timeLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.mas_right).offset(viewPix(10));
        make.top.equalTo(self.iconView).offset(viewPix(4));
    }];
    [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_right).offset(viewPix(6));
        make.centerY.equalTo(self.titleLabel);
        make.width.equalTo(@(viewPix(56)));
        make.height.equalTo(@(viewPix(18)));
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel);
        make.top.equalTo(self.titleLabel.mas_bottom).offset(viewPix(8));
        make.right.equalTo(self.baseView).offset(-viewPix(12));
    }];
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:15];
        _baseView.frame = CGRectMake(viewPix(16), viewPix(8), Screen_W-viewPix(32), viewPix(74));
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UIImageView *)iconView{
    if(!_iconView){
        _iconView = [[UIImageView alloc]initWithFrame:CGRectMake(viewPix(12), viewPix(12), viewPix(50), viewPix(50))];
    }
    return _iconView;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _titleLabel;
}

-(UILabel *)tipLabel{
    if(!_tipLabel){
        _tipLabel = [UILabel lableWithText:@"最近评估" colorString:@"#4C87FD" textFont:LGFontWeight(10, UIFontWeightMedium) textAlignment:NSTextAlignmentCenter lines:1];
        _tipLabel.backgroundColor = [UIColor colorWithString:@"#EAF4FF"];
        _tipLabel.cornerRidus = viewPix(9);
    }
    return _tipLabel;
}

-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _timeLabel;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
